package com.nineclock.approve.nodeResolver.impl;

import cn.hutool.json.JSONObject;
import com.nineclock.approve.nodeResolver.ProcessNodeResolver;
import org.activiti.bpmn.model.Process;
import org.activiti.bpmn.model.StartEvent;

/**
 * @author 黑马程序员
 * @Company http://www.ithiema.com
 * @Version 1.0
 */
public class StartNodeResolver extends ProcessNodeResolver{
    @Override
    public void addFlowNodeToActiviti(Process process, JSONObject currNode, JSONObject nextNode) {
        //绘制 开始节点
        StartEvent startEvent = new StartEvent();
        //id = type + nodeKey
        startEvent.setId(super.getNodeId(currNode));
        // name = node的 name属性
        startEvent.setName(currNode.getStr("name"));

        //添加开始节点  到流程对象中
        process.addFlowElement(startEvent);

        //同时绘制连线节点（跟下一个节点 连线）
        addSequenceFlowToActiviti(process, currNode, nextNode);
    }
}
